package com.zj.system.controller;

import com.seventh.common.pojo.R;
import com.zj.system.pojo.entity.User;
import com.zj.system.pojo.vo.UserVo;
import com.zj.system.service.UserService;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-seventh
 * @description: 用户控制层
 * @author: 张静
 * @create: 2021-07-19 16:20
 **/
@RestController

@RequestMapping("system/user")
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping("sel/{currentPage}/{pageSize}")
    public R selR(@PathVariable("currentPage") Integer currentPage,
                  @PathVariable("pageSize") Integer pageSize,
                  @RequestBody UserVo userVo){
        return userService.sel(pageSize,currentPage,userVo);
    }
    @PutMapping("up/{userId}/{status}")
    public R upStatus(@PathVariable("userId") Integer userId,
                      @PathVariable("status") Integer status){
        return userService.upStatus(userId,status);
    }
    @PutMapping("updateUserById")
    public R update(@RequestBody User user){
        return userService.up(user);
    }
    @PostMapping("insertUser")
    public R insertUser(@RequestBody User user){
        return userService.ins(user);
    }
    @GetMapping("selById/{userId}")
    public R selById(@PathVariable("userId") Integer userId){
        return userService.selById(userId);
    }
    @DeleteMapping("del/{userId}")
    public R del(@PathVariable("userId") Integer userId){
        return userService.del(userId);
    }
    @PostMapping("selUserName")
    public R selUserName(@RequestBody User user){
        return userService.selUserName(user);
    }
}
